
#include "cvm.hpp"

using namespace cvm;

Any::Any(bool x) {
	data.b = x;
	type = &gBool;
}

Any::Any(int x) {
	data.n = x;
	type = &gInt;
}

Any::Any(char x) {
	data.c = x;
	type = &gChar;
}

Any::Any(double x) {
	data.d = x;
	type = &gDbl;
}

Any::Any(PChar x) {
	data.pc = x;
	type = &gCString;
}

Any::Any(FILE* x) {
	data.vp = new File::Impl(x);
	type = &gFile;
}

int BaseType::ToInt(Any& a) { 
	TypeError("can not convert to int"); 
	return a.data.n; 
}
bool BaseType::ToBool(Any& a) { 
	TypeError("can not convert to bool"); 
	return a.data.b; 
}
char BaseType::ToChar(Any& a) { 
	TypeError("can not convert to char"); 
	return a.data.c; 
}
PChar BaseType::ToPChar(Any& a) { 
	TypeError("can not convert to char*"); 
	return a.data.pc; 
}
double BaseType::ToDbl(Any& a) { 
	TypeError("can not convert to double"); 
	return a.data.d; 
}
FILE* BaseType::ToFile(Any& a) { 
	TypeError("can not convert to FILE*"); 
	return NULL; 
}
void StaticSub::Apply(Any& a, VM& vm) {
	vm.ic = vm.funcs[a.ToInt()];
}




int main()
{
	RunTests();
	return 1;
}